package com.mxpio.erp.common.quality.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpioframework.jpa.annotation.DictAble;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Data
@Entity
@Table(name = "v_mb_erp_quality_unqualified_product")
@Schema(description="不合格品查询报表")
@NoArgsConstructor
@AllArgsConstructor
public class VEUnqualifiedProduct implements DictAble, Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Generator
    @Column(name = "ID_", updatable = false)
    @Schema(description = "ID")
    private String id;

//    @Generator(policy = CreatedDatePolicy.class)
    @Column(name = "CREATE_TIME", updatable = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Schema(description = "创建时间")
    private Date createTime;

    @Column(name = "ITEM_CODE_")
    @Schema(description = "物料编码")
    private String itemCode;

    @Column(name = "ITEM_NAME_")
    @Schema(description = "物料名称")
    private String itemName ;

    @Column(name = "ITEM_SPEC_")
    @Schema(description = "规格型号")
    private String itemSpec;

    @Column(name = "DRAWING_NO_")
    @Schema(description = "图号")
    private String drawingNo;

    @Column(name = "UNQUALIFIED_QUANTITY_")
    @Schema(description = "不合格数量")
    private BigDecimal unqualifiedQuantity;

    @Column(name = "BPMN_STATUS_")
    @Schema(description = "审核状态")
    @Dict(dicCode = "ERP_COMMON_BPMN_STATUS")//不良品处理单的审批
    private String bpmnStatus;

    /**审批实例ID*/
    @Column(name = "PROCESS_INSTANCE_ID_")
    @Schema(description = "审批实例ID")//不良品处理单的审批
    private String processInstanceId;

    @Column(name = "APPLY_DECISION_")
    @Schema(description = "申请使用决策")
    @Dict(dicCode = "ERP_QUAL_SUBLOT_USAGE_DECISION")
    private String applyDecision;

    @Column(name = "LINE_NO_", updatable = false)
    @Schema(description = "行号")
    private String lineNo;

    @Column(name = "BIZ_NO_", updatable = false)
    @Schema(description = "处理单单号")
    private String bizNo;

    @Column(name = "INSPECTION_BILL_NO")
    @Schema(description = "质检单单号")
    private String inspectionBillNo;

    @Column(name = "BUSI_TYPE_")
    @Schema(description = "适用业务类型")
    @Dict(dicCode = "ERP_QUAL_IS_BUSI_TYPE")
    private String busiType;

    @Column(name = "ORIGIN_BIZ_TYPE_")
    @Schema(description = "来源单类型")
    @Dict(dicCode="ERP_QUAL_ORIGIN_BIZ_TYPE")
    private String originBizType;

    @Column(name = "ORIGIN_BIZ_NO_")
    @Schema(description = "来源业务单号")
    private String originBizNo;

    @Column(name = "APPLY_ORG_NAME_")
    @Schema(description = "报检组织名称")
    private String applyOrgName;

    @Column(name = "APPLY_ORG_CODE_")
    @Schema(description = "报检组织编码")
    private String applyOrgCode;

    @Column(name = "INSPECTOR_")
    @Schema(description = "检验员")
    @Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
    private String inspector;

    @Column(name = "INSPECTION_FINISH_TIME_")
    @Schema(description = "检验结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date inspectionFinishTime;




    @Transient
    private Map<String, String> textMap;

    public String putText(String key, String value) {
        if (textMap == null) {
            textMap = new HashMap<>();
        }
        return textMap.put(key, value);
    }


}
